# 放置/lib/systemd/system
# 使用systemctl daemon-reload
# 使用systemctl enable auto-conv.service 启用服务
# [Unit]
# Description=Auto-conv-service
# After=nginx.service
#
# [Service]
# Type=idle
# #使用绝对路径，【】方框内填入py文件绝对路径
# ExecStart=/usr/bin/python 【】
# ExecReload=/usr/bin/python 【】
# #【】内填入
# User=【】
# Group=users
#
# [Install]
# WantedBy=multi-user.target

#!/bin/bash

# 软件路径
pypath=
# 用户名称
username=

echo -e "[Unit]\nDescription=Auto-conv-service\nAfter=nginx.service\n\n[Service]\nType=idle\nExecStart=/usr/bin/python [pypath]\nExecReload=/usr/bin/python [pypath]\nUser=[username]\nGroup=users\n\n[Install]\nWantedBy=multi-user.target">auto-conv.service
sed -i 's/\[pypath\]/'$pypath'/g' auto-conv.service
sed -i 's/\[username\]/'$username'/g' auto-conv.service

sudo mv auto-conv.service /lib/systemd/system/auto-conv.service
sudo systemctl daemon-reload
sudo systemctl enable auto-conv.service
